package com.jinke.api.modules.ums.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jinke.api.modules.ums.mapper.ApiLogMapper;
import com.jinke.api.modules.ums.model.ApiLog;
import com.jinke.api.modules.ums.service.IApiLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author huang
 * @data 2024-05-16
 */
@Slf4j
@Service
public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper, ApiLog> implements IApiLogService {
    @Override
    public void saveApiLog(String strResult, String orderNo, String requestTypeName) {
        // 这里先注释掉确保只执行三个参数的方法
        if (strResult!=null&&strResult.length()>3000){
            log.error("结果过长"+orderNo);
            strResult=strResult.substring(0,3000);
        }
        String finalStrResult = strResult;
        Thread thread = new Thread(() -> {
            ApiLog apiLog = new ApiLog();
            apiLog.setOrderNo(orderNo);
            apiLog.setRequestTypeName(requestTypeName);
            apiLog.setResult(finalStrResult);
            save(apiLog);
        });
        thread.start();
    }






}
